package com.wangyongliang.personalcenterproducer.web;


import com.wangyongliang.common.dto.UserDto;
import com.wangyongliang.common.vo.ResultEntity;
import com.wangyongliang.personalcenterproducer.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 王永亮
 * @since 2020-03-24
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    IUserService iUserService;

    @RequestMapping("getcode")
    public ResultEntity getCode(UserDto userDto){
//        String endPhone = phone.substring(7, -1);
//        Wrapper wrapper = new EntityWrapper<User>();
//        wrapper.like("phone",phone);
//        List<User> list = iUserService.selectList(wrapper);
//        list.get(0).getPhone()
        boolean code = iUserService.getCode(userDto.getPhone());
        return ResultEntity.ok(code);
    }

    @RequestMapping("codeinfo")
    public ResultEntity codeinfo(UserDto userDto){
        String codeinfo = iUserService.codeinfo(userDto);
        if (codeinfo.equals("1")){
            return ResultEntity.ok();
        }
        return ResultEntity.error(codeinfo);
    }
}
